package com.landcode.land.user.controller;

import com.landcode.land.user.model.User;
import com.landcode.land.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping(value = "/{id}")
    public User addUser(@PathVariable long id) {
        return userService.getUser(id);
    }

    @GetMapping(value = "/list")
    public List<User> getUsers() {
        return userService.selectUserList();
    }

    @PostMapping(value = "/add")
    public int addUser(@RequestBody User user) {
        return userService.addUser(user);
    }
}
